const app = getApp()
const { fetchVisitCode } = require('../../utils/api.js')
import Storage from '../../utils/storage'
Page({
	data: {
		navBarHeight: app.globalData.navBarHeight,
		show: false,
		info: {
			accessTime:"2025-10-01 12:00:00"
		},
		list: [
			{
				name:"李志"
			}
		]
	},
	onShow() {
		const token = Storage.get('token') || null
		if (token) {
			this.initCodes()
		}
	},
	initCodes: async function () {
		const result = await fetchVisitCode()
		if (result.code == 200) {
			this.setData({
				info: result.data,
				list: result.data.visitorPersons
			})
		}
	},
	naviToPage: function (event) {
		const url = event.currentTarget.dataset.url
		wx.navigateTo({
			url: url
		})
	},
	seeRcode: function (e) {
		const id = e.currentTarget.dataset.id
		this.setData({
			show: true
		})
	},
	closeRcode: function () {
		this.setData({
			show: false
		})
	}
})